home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / glibc-1.09 / glibc-1 / glibc-1.09.1 / sysdeps / mach / hurd / mips / exc2signal.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-08  |  2.4 KB  |  99 lines

  1. /* Translate Mach exception codes into signal numbers.  MIPS version.
  2. Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4.  
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public License as
  7. published by the Free Software Foundation; either version 2 of the
  8. License, or (at your option) any later version.
  9.  
  10. The GNU C Library is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. Library General Public License for more details.
  14.  
  15. You should have received a copy of the GNU Library General Public
  16. License along with the GNU C Library; see the file COPYING.LIB.  If
  17. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  18. Cambridge, MA 02139, USA.  */
  19.  
  20. #include <hurd.h>
  21. #include <hurd/signal.h>
  22. #include <mach/exception.h>
  23.  
  24. /* Translate the Mach exception codes, as received in an `exception_raise' RPC,
  25.    into a signal number and signal subcode.  */
  26.  
  27. void
  28. _hurd_exception2signal (int exception, int code, int subcode,
  29.             int *signo, int *sigcode, int *error)
  30. {
  31.   *error = 0;
  32.  
  33.   switch (exception)
  34.     {
  35.     default:
  36.       *signo = SIGIOT;
  37.       *sigcode = exception;
  38.       break;
  39.       
  40.     case EXC_BAD_ACCESS:
  41.       if (code == KERN_PROTECTION_FAILURE)
  42.     *signo = SIGSEGV;
  43.       else
  44.     *signo = SIGBUS;
  45.       *sigcode = subcode;
  46.       *error = code;
  47.       break;
  48.  
  49.     case EXC_BAD_INSTRUCTION:
  50.       *signo = SIGILL;
  51.       if (code == EXC_MIPS_II)
  52.     *sigcode = code;
  53.       else
  54.     *sigcode = 0;
  55.       break;
  56.       
  57.     case EXC_ARITHMETIC:
  58.       switch (code)
  59.     {
  60.     case EXC_MIPS_OV:    /* integer overflow */
  61.       *signo = SIGFPE;
  62.       *sigcode = EXC_MIPS_FLT_OVERFLOW;
  63.       break;
  64.  
  65.     default:
  66.       *signo = SIGFPE;
  67.       *sigcode = 0;
  68.       break;
  69.  
  70.     case EXC_MIPS_INT:
  71.       /* Subcode is the fp_status word saved by the hardware.
  72.          Give an error code corresponding to the first bit set.  */
  73.       if (subcode == EXC_MIPS_FLT_UNIMP)
  74.         *signo = SIGILL;
  75.       else
  76.         *signo = SIGFPE;
  77.       *sigcode = subcode;
  78.       break;
  79.     }
  80.       break;
  81.  
  82.     case EXC_EMULATION:        
  83.       /* 3.0 doesn't give this one, why, I don't know.  */
  84.       *signo = SIGEMT;
  85.       *sigcode = 0;
  86.       break;
  87.  
  88.     case EXC_SOFTWARE:
  89.       *signo = SIGEMT;
  90.       *sigcode = 0;
  91.       break;
  92.       
  93.     case EXC_BREAKPOINT:
  94.       *signo = SIGTRAP;
  95.       *sigcode = code;
  96.       break;
  97.     }
  98. }
  99.